package com.vegetable.modules.controller.baseData;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vegetable.common.utils.R;
import com.vegetable.modules.controller.AbstractController;
import com.vegetable.modules.entity.baseData.po.AccountDetailsQueryPO;
import com.vegetable.modules.entity.finance.po.ADCanPayPO;
import com.vegetable.modules.service.baseData.IAccountDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  往来明细 前端控制器
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-21
 */
@Slf4j
@RestController
@RequestMapping("/accountDetails")
@AllArgsConstructor
@Api(value = "往来明细", tags = "往来明细")
public class AccountDetailsController extends AbstractController {

    private IAccountDetailsService accountDetailsService;

    /**
     * 所有往来明细列表
     */
    @PostMapping("/list")
    @ApiOperation(value = "条件查询往来明细列表", notes = "条件查询往来明细列表")
    public R list(@RequestBody AccountDetailsQueryPO po){
        log.info("条件查询往来明细列表{}", JSON.toJSONString(po));
        IPage page = accountDetailsService.queryPage(po);
        return R.data( page);
    }

    @PostMapping("/teamStatistics")
    @ApiOperation(value = "条件查询往来明细列表", notes = "条件查询往来明细列表")
    public R teamStatistics(@RequestBody ADCanPayPO po){
        IPage iPage = new Page(po.getPage(), po.getLimit());
        IPage page = accountDetailsService.teamStatistics(iPage, po);
        return R.data( page);
    }

    @PostMapping("/canPaymentList")
    @ApiOperation(value = "查询可收款的待办交货", notes = "查询可收款的待办交货")
    public R canPaymentList(@RequestBody AccountDetailsQueryPO po){
        IPage list= accountDetailsService.canPaymentList(po);
        return R.data(list);
    }



}
